/*
 * @Author: Troubadour 2276791354@qq.com
 * @Date: 2024-06-06 14:14:51
 * @LastEditors: Troubadour 2276791354@qq.com
 * @LastEditTime: 2024-06-06 14:16:44
 * @Version:
 * @Description:
 */

#ifndef __W25Q32_H
#define __W25Q32_H

/*-------------------------------------------------------------------------------------------------------------------------------------
-                                                  Include file                                                                       -
--------------------------------------------------------------------------------------------------------------------------------------*/

#include <main.h>
#include <stdbool.h>
/*-------------------------------------------------------------------------------------------------------------------------------------
-                                                  External macro                                                                     -
--------------------------------------------------------------------------------------------------------------------------------------*/

/* factory data. */
#define FAL_PARTITION_FACTORY_DATA_NAME     "factory"
#define FAL_PARTITION_FACTORY_DATA_ADDR     (0)
/* Unit: Byte. */
#define FAL_PARTITION_FACTORY_DATA_SIZE     (10 * 1024)

/* user data. */
#define FAL_PARTITION_USER_DATA_NAME        "user"
#define FAL_PARTITION_USER_DATA_ADDR        (FAL_PARTITION_FACTORY_DATA_ADDR + FAL_PARTITION_FACTORY_DATA_SIZE)
/* Unit: Byte. */
#define FAL_PARTITION_USER_DATA_SIZE        (10 * 1024)

/* OTA data. */
#define FAL_PARTITION_OTA_DATA_NAME         "OTA"
#define FAL_PARTITION_OTA_DATA_ADDR         (FAL_PARTITION_USER_DATA_ADDR + FAL_PARTITION_USER_DATA_SIZE)
/* Unit: Byte. */
#define FAL_PARTITION_OTA_DATA_SIZE         (1024 * 1024)

/* Other data. */
#define FAL_PARTITION_OTHER_DATA_NAME       "Ohter"
#define FAL_PARTITION_OTHER_DATA_ADDR       (FAL_PARTITION_OTA_DATA_ADDR + FAL_PARTITION_OTA_DATA_SIZE)
/* Unit: Byte. */
#define FAL_PARTITION_OTHER_DATA_SIZE       (1024 * 1024)
/*-------------------------------------------------------------------------------------------------------------------------------------
-                                                  External enum                                                                      -
--------------------------------------------------------------------------------------------------------------------------------------*/


/*-------------------------------------------------------------------------------------------------------------------------------------
-                                                  External structure                                                                 -
--------------------------------------------------------------------------------------------------------------------------------------*/


/*-------------------------------------------------------------------------------------------------------------------------------------
-                                                  External variables                                                                 -
--------------------------------------------------------------------------------------------------------------------------------------*/


/*-------------------------------------------------------------------------------------------------------------------------------------
-                                                  External function                                                                  -
--------------------------------------------------------------------------------------------------------------------------------------*/


uint8_t BSP_W25Qx_Init(void);
static void	BSP_W25Qx_Reset(void);
static uint8_t BSP_W25Qx_GetStatus(void);
uint8_t BSP_W25Qx_WriteEnable(void);
void BSP_W25Qx_Read_ID(uint8_t *ID);
bool BSP_W25Qx_Read(uint8_t* pData, uint32_t ReadAddr, uint32_t Size);
uint8_t BSP_W25Qx_Write(uint8_t* pData, uint32_t WriteAddr, uint32_t Size);
uint8_t BSP_W25Qx_Erase_Block(uint32_t Address);
uint8_t BSP_W25Qx_Erase_Chip(void);

#endif
